package com.shenmazong.fastdfs.controller;

import com.shenmazong.utils.VerifyCodeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;

/**
 * @author 军哥
 * @version 1.0
 * @description: 验证码接口
 * @date 2022/2/11 21:29
 */

@Controller
@RequestMapping(value = "/user")
public class VerifyCodeController {

    // 默认是4位随机数字
    @GetMapping(value = "/code1")
    public String code1(HttpServletResponse response) {
        String code = VerifyCodeUtil.code().getCode(response);
        return code;
    }

    // 自定义验证码
    @GetMapping(value = "/code2")
    public String code2(HttpServletResponse response) {
        String randCode = "1234";
        String code = VerifyCodeUtil.code().getCode(response, randCode);
        return code;
    }

    // 自定义验证码长度
    @GetMapping(value = "/code3")
    public String code3(HttpServletResponse response) {
        String code = VerifyCodeUtil.code().setLength(6).getCode(response);
        return code;
    }

    // 自定义验证码字典
    @GetMapping(value = "/code4")
    public String code4(HttpServletResponse response) {
        String code = VerifyCodeUtil.code().setRandText("ABCDEFG").getCode(response);
        return code;
    }

    // 自定义验证码的大小
    @GetMapping(value = "/code5")
    public String code5(HttpServletResponse response) {
        String code = VerifyCodeUtil.code().setSize(200, 80).getCode(response);
        return code;
    }
}
